package com.stylefeng.guns.modular.vpn.utils;

import java.util.List;

/**
 * @Description TODO
 * @Author Mr.GodRui
 * @Date 2020-04-17 20:26
 **/
public class PlatformUtil {

    public static String getPlatformName(int p){
        String str = "";
        if (p == 1){
            str = "Android";
        }
        else if (p == 2){
            str = "IOS";
        }
        else if (p == 3){
            str = "Windows";
        }
        else if (p == 4){
            str = "Mac";
        }
        else if (p == 5){
            str = "Web";
        }
        return str;
    }

    /**
     * 获取平台+版本号的拼接标识
     * @param platform
     * @param versionName
     * @return
     */
    public static String getPVKey(String platform,String versionName){
        return platform+"("+versionName+")";
    }

    public static String getPVKey(int platform,String versionName){
        return getPVKey(getPlatformName(platform),versionName);
    }

    public static Integer[] getCounts(int size){
        Integer[] counts = new Integer[size];
        for (int i = 0; i < size; i++) {
            counts[i] = 0;
        }
        return counts;
    }

    /**
     * 获取某对象在集合中的下标位置
     * @param list
     * @param obj
     * @return
     */
    public static int getIndex(List<String> list,String obj){
        int len = list.size();
        for (int i = 0; i < len; i++) {
            if (list.get(i).equals(obj)){
                return i;
            }
        }
        return -1;
    }

}
